﻿
@{
    ViewBag.Title = "add";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@model YTCMS.Domain.Entities.content
<link href="/Content/uploadify.css" rel="stylesheet" />
<script src="/Scripts/jquery.uploadify.js"></script>
<style type="text/css">
    .uploadify-button {
        /*background: url("/Content/img/upload1.png");*/
        border: 0;
        border-radius: 0;
        display: inline-block;
        margin-left: 1px;
        position: absolute;
        top: 0;
        left: 0;
    }

    .makefriend .tag .btn {
        width: 100%;
        height: 20px;
        border-radius: 0px;
        font-size: 12px;
        background-color: #fb9337;
        color: #fff;
        box-shadow: -2px 2px rgba(158, 153, 153, 0.47);
        margin: 0 10px 0 0;
        padding: 3px 6px;
        text-align: center;
        display: inline;
        white-space: normal;
    }

    .makefriend .btn {
        width: 100px;
        height: 40px;
        background-color: #d93467;
        border-radius: 8px;
        font-size: 18px;
        display: inline-block;
        box-shadow: -1px 1px #ddd;
    }

        .makefriend .btn:hover {
            background-color: #d93467;
        }
    /*.makefriend .modal-dialog{
      width: 320px;
      margin: 350px auto 0;
      text-align: center;
    }*/
    .makefriend .modal-content {
        width: 320px;
        padding: 30px 40px 20px;
        margin: 10% auto 0;
        text-align: center;
    }

    .makefriend .hislabel {
        width: 100%;
        /*text-align: left;*/
        font-size: 12px;
    }

    .makefriend .level {
        text-align: center;
    }

    .expdiv {
        padding: 4px;
        width: 80px;
        border: 1px solid #c8c8c8;
        float: left;
    }

    .expbtn {
        position: absolute;
        z-index: 2;
        margin: -15px 0px 0px 50px;
    }

        .expbtn a {
            display: block;
            width: 32px;
            height: 32px;
            background: #fff;
            background: url(/Content/img/Stop.png);
        }

    /*.expbtn a:hover {
        background: url(../images/btn_playbg.gif) left -16px;
    }*/
</style>

<script charset="utf-8" src="/Content/kindeditor/kindeditor-min.js"></script>
<script charset="utf-8" src="/Content/kindeditor/lang/zh_CN.js"></script>
<div class="page-header">
    <h1>
        模块管理
        <small>
            <i class="icon-double-angle-right"></i>
            新增内容
        </small>
    </h1>
</div><!-- /.page-header -->

<div class="row">
    <div class="col-xs-12">
        <div class="row">
            <div class="col-xs-12 ">

            </div>
        </div>
        <div class="row">
            <div class="col-xs-12">
                <form class="form-horizontal" role="form" id="form1" method="post" action="/ads/add">
                    <div class="form-group">
                        <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 标题 </label>
                        <div class="col-sm-9">
                            @Html.TextBoxFor(s => s.Title, new { @class = "col-xs-10 col-sm-5 required" })
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 副标题 </label>
                        <div class="col-sm-9">
                            @Html.TextBoxFor(s => s.ETitle, new { @class = "col-xs-10 col-sm-5 " })
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 排序 </label>
                        <div class="col-sm-9">
                            @Html.TextBoxFor(s => s.Sort, new { @class = "col-xs-10 col-sm-5 required digits" })
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 属性 </label>
                        <div class="col-sm-9">
                            @Html.TextBoxFor(s => s.Attribute, new { @class = "col-xs-10 col-sm-5 " })
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> SEO关键字 </label>
                        <div class="col-sm-9">
                            @Html.TextBoxFor(s => s.SEOKeyword, new { @class = "col-xs-10 col-sm-5 " })
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> SEO描述 </label>
                        <div class="col-sm-9">
                            @Html.TextAreaFor(s => s.SEODescribe, new { @class = "col-xs-10 col-sm-5", @style = "margin: 0px; width: 767px; height: 76px;" })
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 所属栏目 </label>
                        <div class="col-sm-9">
                            @Html.DropDownListFor(s => s.Cid, Admin.Common.YTDDL.Cmscolumn(s => s.State == (int)YTCMS.Core.CommonState.正常), new { @class = "col-xs-10 col-sm-5" })
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 作者 </label>
                        <div class="col-sm-9">
                            @Html.TextBoxFor(s => s.Author, new { @class = "col-xs-10 col-sm-5 " })
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 来源 </label>
                        <div class="col-sm-9">
                            @Html.TextBoxFor(s => s.Source, new { @class = "col-xs-10 col-sm-5 " })
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 外联URL </label>
                        <div class="col-sm-9">
                            @Html.TextBoxFor(s => s.Url, new { @class = "col-xs-10 col-sm-5 " })
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 标题图片 </label>
                        <div class="col-sm-9">
                            <input type="file" name="file_upload" id="file_upload" maxlength="200" />
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label no-padding-right" for="form-field-1">  </label>
                        <div class="col-sm-9" id="divimg">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 内容 </label>
                        <div class="col-sm-9">
                            @Html.TextAreaFor(s => s.Remark, new { @class = "col-xs-10 col-sm-5", @style = "margin: 0px; width: 767px; height: 76px;" })
                        </div>
                    </div>
                    <div class="clearfix form-actions">
                        <div class="col-md-offset-3 col-md-9">
                            <button class="btn btn-info" type="button" id="btnSave">
                                <i class="icon-ok bigger-110"></i>
                                新增
                            </button>

                            &nbsp; &nbsp; &nbsp;
                            <button class="btn" type="reset">
                                <i class="icon-undo bigger-110"></i>
                                撤销
                            </button>
                        </div>
                    </div>
                    @Html.Hidden("hidimg")
                </form>
            </div><!-- /span -->
        </div><!-- /row -->
    </div><!-- /.col -->
</div><!-- /.row -->

<script type="text/javascript">
    var imgs = new Array();
    $(function () {
        $("#btnSave").click(function () {
            $("#hidimg").val(imgs.toString())
            var b = jQuery("#form1").valid();
            if (b) {
                $.post("/Content/add", $("#form1").serialize(), function (data) {
                    if (data.d) {
                        jAlert("新增成功", "提示", function () {
                            location.href = "/Content/index";
                        })
                    }
                    else {
                        jAlert(data.msg, "提示");
                    }
                })
            }
        });
        var editor;
        KindEditor.ready(function (K) {
            editor = K.create('textarea[name="Remark"]', {
                uploadJson: '/Util/KindEditorHandlerFile',
                afterBlur: function () { editor.sync(); },
                allowFileManager: true
            });
        });
    })

    setTimeout(function () {
        jQuery('#file_upload').uploadify({
            'swf': '/Scripts/uploadify.swf',
            'uploader': '/Util/ImgUpload',
            'fileTypeExts': '*.gif; *.jpg; *.png; *.bmp; *.jpeg',
            'multi': false,
            'fileObjName': 'filedata',
            'wmode': 'transparent',
            'fileSizeLimit': '2MB',
            'onSelectError': function (file, errorCode, errorMsg) {
                jAlert("文件大小超出系统限制的", "提示")
            },
            'onFallback': function () {
                jAlert("您未安装FLASH控件，无法上传图片！请安装FLASH控件后再试。", "提示");
            },
            onUploadSuccess: function (file, data, respone) {
                $("#divimg").empty().append("<div class='expdiv'><div class='expbtn'><a href='javascript:void(0)' onclick='imgclose(this)' value='" + data + "'></a></div><img src='" + data + "' height='100px' width='80px' /></div>")
                imgs.push(data);
            }
        });
    }, 10);
</script>
